package com.zhj.pay;

import android.content.Intent;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.telecom.Call;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.Map;

public class MainActivity extends AppCompatActivity implements View.OnClickListener{


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        PluginManager.getsInstance().setContext(this);

        // /storage/emulated/legacy
//        File path = Environment.getExternalStorageDirectory();
//        Log.d("which","path=" + path);


//        String path = "/storage/emulated/legacy";
//        File file = new File(path,"a.txt");
//        if(file.exists()){
//            Log.d("which","文件存在");
//        }else {
//            Log.d("which","文件不存在");
//        }


        findViewById(R.id.btn_load).setOnClickListener(this);
        findViewById(R.id.btn_click).setOnClickListener(this);



    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn_load:
                File file = new File(Environment.getExternalStorageDirectory(),"plugin.apk");
                PluginManager.getsInstance().loadApk(file.getAbsolutePath());

                break;
            case R.id.btn_click:
                Intent intent = new Intent(this,ProxyActivity.class);
                intent.putExtra("className",PluginManager.getsInstance().getPackageInfo().activities[0].name);
                startActivity(intent);
                break;
        }
    }



}
